package com.example.administrator.testdagger;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.example.administrator.testdagger.exception.RemindStrException;

/**
 * com.example.administrator.testdagger
 * (c)2018 AIR Times Inc. All rights reserved.
 *
 *
 * @author WangJQ
 * @version 1.0
 * @date 2018/6/25 18:53
 * @see com.example.administrator.testdagger
 */
public class Util {

    /**
     * 用于检查多个非空事件
     * @param context 上下文
     * @param views 需要判断是否填写字段的
     * @param mentions 提示词语
     * @return
     */
    public static boolean checkNull(Context context, TextView[] views, String[] mentions) {
        if (views == null || mentions == null || views.length == 0 || mentions.length == 0 || views
                .length != mentions.length) {
            try {
                throw new RemindStrException("数组异常，请检查数组");
            } catch (Exception e) {

            }
        }

        for (int i = 0; i < views.length; i++) {
            if (TextUtils.isEmpty(views[i].getText().toString().trim())) {
                Toast.makeText(context, mentions[i], Toast.LENGTH_SHORT).show();
                return false;
            }
        }
        return true;
    }

    private void setObject(String ... str){
        for (int i = 0; i < str.length; i++) {

        }
        for (String s:str) {

        }
    }
}
